import com.beans.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class App {
    public static void main(String[] args) {

        //得到sping上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //根据上下文对象提供的方法拿到bean
        User user = (User) context.getBean("user");
        User user1 = context.getBean(User.class);

        //使用
        user.sayHi("陶俊臣");
        user1.sayHi("tjc");
//        BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("spring-config.xml"));
//        User user = (User) beanFactory.getBean("user");
//        user.sayHi("陶俊臣");



    }
}
